<%-- 
    Document   : movieList
    Created on : May 1, 2013, 5:39:55 PM
    Author     : DevSteve
--%>

<%@page import="java.util.List"%>
<%@page import="java.io.FileReader"%>
<%@page import="java.io.IOException"%>
<%@page import="java.io.BufferedReader"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.FileNotFoundException"%>
<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.File"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="db.DB"%>
<%@page import="db.MovieObj"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <title>Dataflix</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta http-equiv="content-language" content="en" />
        <meta name="description" content="" />
        <meta name="language" content="en" />
        <link type="text/css" rel="stylesheet" href="../css/style.css"/>
        <link type="text/css" rel="stylesheet" href="../css/style.css"/>
        <link type-="text/css" rel="stylesheet" href="../css/jquery-ui-1.9.2.custom.min.css"/>
        <link type-="text/css" rel="stylesheet" href="../css/timeline.css"/>
        <link type-="text/css" rel="stylesheet" href="../css/bootstrap.min.css"/>
        <style type="text/css">
            body {
                padding-bottom: 40px;
            }
            .sidebar-nav {
                padding: 9px 0;
            }
        </style>
        <script src="../js/jquery-1.9.1.min.js"></script>
        <script src="../js/jquery-ui-1.9.2.custom.min.js"></script>
        <script src="../js/bootstrap.min.js"></script>
        <script>

        </script>

    <head>
    <body>
         <% 
            String userId = request.getParameter("userId");
        %>
        <table id="head">
            <tr>
                <td>
                    <a href="employee.jsp?userId=<%=userId %>" /><img style="margin-left:10%;" src="../images/logoadmin.png"/></a>
                </td>

                <td>
                    <table id="loginbox">
                        <tr>
                            <td width="40%">
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <div class="bottom"></div>
        <div class="container-fluid">
            
         <h3>
             Customer Representer Page 
            <INPUT Type="BUTTON" class="btn" value="Customer list add/edit/delete" onclick="window.location.href = 'customerList.jsp?userId=' + '<%= userId %>';" />
            <INPUT Type="BUTTON"  class="btn" value="Customer mailing list" onclick="window.location.href = 'customerMailingList.jsp?userId='+ '<%= userId %>';" />
            <INPUT Type="BUTTON"  class="btn" value="Unreturned movie list" onclick="window.location.href = 'unreturnedMovie.jsp?userId='+ '<%= userId %>';" />

        </h3>
            <table class="table">
            
                <% 
                java.sql.Connection con;
                java.sql.Statement s;
                java.sql.ResultSet rs;
                java.sql.PreparedStatement pst;

                con=null;
                s=null;
                pst=null;
                rs=null;

                DB data=new DB();

                
                String sql = "SELECT Rental.Id, Movie.Name, Users.Email, Rental.Date, Rental.ReturnDate FROM Rental INNER JOIN Movie ON Movie.Id = Rental.MovieId  INNER JOIN Users ON Users.Id = Rental.CustomerId WHERE Rental.employeeId=-1  order by Date DESC;";
                try{
                    con = data.getConnection();
                    s = con.createStatement();
                    rs = s.executeQuery(sql);
                %>
                <thead>
                <tr>
                <th style=" text-align: left;" width="80px;">Order Id</th>
                <th style=" text-align: left;" width="200px;">Renter Email</th>
                <th style=" text-align: left;" width="300px;">Order Movie</th>
                <th style=" text-align: left;" width="300px;">Order Date</th>
                <th style=" text-align: left;">Record</th>
                </tr>
                </thead>
                
                <tbody id ="gridBody"> 
                <%
                while( rs.next() ){
                    String id = rs.getString("Id");
                %><tr>
                <td style=" text-align: left;"><%= rs.getString("Id") %></td>
                <td style=" text-align: left;"><%= rs.getString("Email") %></td>
                <td style=" text-align: left;"><%= rs.getString("Name") %></td>
                <td style=" text-align: left;"><%=rs.getString("Date").toString()%></td>
                <td style=" text-align: left; vertical-align: bottom;"><INPUT Type="BUTTON" class="btn" value="Okay" onclick="window.location.href = 'updateOrder.jsp?orderId='+'<%=id%>' +'&userId='+ '<%= userId%>'" /></td>
                </tr>
                <%
                }
                %>

                <%

                }
                catch(Exception e){e.printStackTrace();}
                finally{
                if(rs!=null) rs.close();
                if(s!=null) s.close();
                if(con!=null) con.close();
                }

                %>
                </tbody>
            </table>
           
        </div>
    <body>
</html>



